<html>
<head>
 <meta charset="utf-8">
    <title>金韦尔后台-首页</title>
    <!--这个地方放引入的css，或者js文件， <script>方法一般放在最下面</script>-->
    <link href="./css/login.css" rel="stylesheet">
    <script src="./js/jquery-3.1.1.min.js"></script>
</head>

<body class="c" onkeydown="keyLogin();">
      <div class="header">
        <h1>HEARTSYS</h1>
        <div class="right">
          <h4>从前质疑网络&nbsp;&nbsp;&nbsp;现在不可或缺&nbsp;&nbsp;&nbsp;未来···</h4>
        </div>
      </div>

      <div class="main">
        <div class="main-p">
          <div class="title">
            <h1>H-SET定制建站系统</h1>
            <div class="one">
              <span>HEARTSYS建站系统</span>
              <span>·</span>
              <span>H-SET定制建站系统专业为用户量身定制专属方案</span>
            </div>
          </div>

          <div class="feedIn">
            <input type="text" placeholder="用户名" id="name"/>

            <i class="user"></i>

            <input type="password" placeholder="密码" id="password"/>
            <i class="lock"></i>
          </div>
          <button  class="submit" onclick="login()">登录</button>
        </div>
      </div>
    </body>
</html>

<script >

    function keyLogin(){
     if (event.keyCode==13){  //回车键的键值为13
        login();
      }
    }
    function login() {
        var user=$("#name").val();
        var password=$("#password").val();
        $.ajax({
            type: "POST",
            url: "../login/loginCheck",
            data: {account:user, password:password},
            dataType: "json",
            success: function(data){
                console.log(data);
                if(data.code=="fail"){
                alert("用户名或者密码错误，请重新登录");
                }else{
                alert("恭喜登录成功");
                }
            },
        })
    }
</script>